package main

import "fmt"

type People interface {
	Speak(string) string
}
type Student struct {}

func (Std *Student) Speak(str string) (talk string) {
	if str == "sb" {
		talk = "你是个大帅哥"
	} else {
		talk = "您好"
	}
	return
}

func main() {
	//var peo People = Student{}  //指针接收者实现接口

	//st := new(Student)

	//st.Speak();

	var peo People = &Student{}
	think := "bitch"
	fmt.Println(peo.Speak(think))

	//空接口的应用
	var studentInfo = make(map[string]interface{})
	studentInfo["name"] = "小米"
	fmt.Println(studentInfo)
	var x interface{}
	s := "hello 啊啊"
	x = s
	x = 100
	fmt.Printf("%T %v", x, x)
	fmt.Println()
	duanyan()
}

func duanyan()  {

	var x interface{}
	x = "hello 单独"
	v,ok := x.(string)
	if ok {
		fmt.Println(v)
	} else {
		fmt.Println("断言失败")
	}
}

